home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <appkit/NXBitmapImageRep.h>
- #include <streams/streams.h>
- #include "pcxlib.h"
- #include "ImageControl.h"
-
- void main(int argc, char *argv[])
- {
- id image;
- NXStream *outStream;
- FILE *outFile;
- id imageCon;
- unsigned char *data, r[256], g[256], b[256];
-
- image = [[NXBitmapImageRep alloc] initFromFile: argv[1]];
-
- outFile = fopen("out.pcx", "w");
- outStream = NXOpenFile(fileno(outFile), NX_WRITEONLY);
-
- imageCon = [ImageControl new: image];
-
- [imageCon convertToPalette: 256
- andReturn: &data
- andPalettes: r:g:b];
-
- pcxwrite(outStream,
- data, r, g, b,
- [image pixelsWide],
- [image pixelsHigh],
- 256);
-
- NXClose(outStream);
- fclose(outFile);
- [image free];
- }
-